<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="skin/base.css" type="text/css"  />
<link rel="stylesheet" type="text/css" href="skin/user.css">
<link rel="stylesheet" href="skin/btn.css" type="text/css" />
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/zy_json.js"></script>
<script src="js/login.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js"></script>
</head>
<body ontouchstart>
<div id="main">
  <div class="user">
    <div class="user_my_head">
    	<div class="bg"></div>
    
      <div class="avatar" ontouchstart="zy_touch('down')" id="avatar"></div>
      <div class="nk" id='nk' ></div>
      <div class="praise yes"><span>1</span></div>
      <ul id="button">
      	<li onclick="relation(1)">未关注</li>
   	  </ul>
    </div>
   
    <ul class="user_my_menu">
    	<li id="gender"></span></li>
		<li id="site"></span></li>
		<li id="platforms"></li>
		<li id="expertise"></li>
		<li id="lastLoginTime"></span></li>
		<li id="joinTime"></span></li>
    </ul>
  </div>
</div>
</body>
<script>
    zy_init();
	var Users= new Users({});

	function oklogin(){
			if(!Users.checkUser()){
				localStorage['login']="userother";
				uexWindow.open('login', '0', 'login.html', 2, '', '', 0x0);
				return false;
			}else{
				uexWindow.toast(1, 5, '加载中...', 0);
				var url = OpenAPI.user_information+'/?client_id='+OpenAPI.client_id+'&access_token='+localStorage['access_token']+'&friend='+localStorage['friend_id'];
				//logs(url);
				uexXmlHttpMgr.open(1,'post',url,"8000");
				uexXmlHttpMgr.send(1);
			}

	}
	
	function update_user_relation(relation){
		
		var url = OpenAPI.user_relation+'/?client_id='+OpenAPI.client_id+'&access_token='+localStorage['access_token']+'&friend='+localStorage['friend_id']+'&relation='+relation;
		//logs(url);
		$.getJSON(url,function(data){
			if (data['error'] == 200) {
				uexWindow.toast("0","5",data['error_description'],1000);
			}else{
				uexWindow.toast("0","5","操作失败",1000);
			}
		});
	}
	
	window.uexOnload = function(type){
		if (!type) {
	
			uexWindow.setBounce("1");
			uexWindow.showBounceView("0","#666","0");
			uexWindow.showBounceView("1","#666","0");
			uexXmlHttpMgr.onData = function(opId, status, data){
				uexXmlHttpMgr.close(opId);
				if (status == 1) {
					data = JSON.parse(data);
					uexWindow.closeToast();
					if(opId ==1){
						if(data['user']){
							var li = '';
							switch(parseInt(data['relation']))
							{
							case 1:
								li = '<li onclick="update_user_relation(0)">已关注</li>';	
							  	break;
							case 2:
								li = '<li onclick="update_user_relation(0)">相互关注</li>';
							  	break;
							case 3:
								li = '<li onclick="update_user_relation(1)">未关注</li>';
							  	break;
							}
							$$('button').innerHTML=li;
							$$('avatar').innerHTML = '<img src="' + data['portrait'] + '" />';
							$$('gender').innerHTML = data['gender']==1 ? '性　　别：男' : '性　　别：女';
							$$('site').innerHTML = '地　　址：'+data['province']+' '+data['city'];
							$$('platforms').innerHTML = '开发平台：'+data['platforms'];
							$$('expertise').innerHTML = '专长领域：'+data['expertise'];
							$$('lastLoginTime').innerHTML = '最近登录：'+data['lastLoginTime'];
							$$('joinTime').innerHTML = '加入时间：'+data['joinTime'];
							
						}else{
							uexWindow.toast("0", "5", '请求个人资料失败', 1000);
						}
					}
				}else if(status ==-1){
					uexWindow.toast("0", "5", '请求超时', 1000);
				}
			}
			oklogin();
		}
	}
	
</script>
</html>